package com.jacken.springcloudseatabank02.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jacken.springcloudseatabank02.entity.AccountInfo;
import com.jacken.springcloudseatabank02.mapper.AccountInfoMapper;
import com.jacken.springcloudseatabank02.service.IAccountService;
import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author wangqiang
 * @version 1.0
 * @date 2020/10/8 9:30
 */
@Service
public class IAccountServiceImpl extends ServiceImpl<AccountInfoMapper, AccountInfo> implements IAccountService {


    @Resource
    private AccountInfoMapper accountInfoMapper;


    /**
     * 更新账户金额
     *
     * @param accountNo      账户
     * @param accountBalance 金额
     */
    @Override
    @Transactional  //开启本地事务
    public void updateAccountBalance(String accountNo, Double accountBalance) {
        System.out.println("xid===>"+ RootContext.getXID());
        //增加李四的金额
        accountInfoMapper.updateAccountBalance(accountNo, accountBalance);

    }
}
